package hanqi.mangement.Controller;

import hanqi.mangement.Service.gradeservice;
import hanqi.mangement.entity.grade;
import hanqi.mangement.entity.gradebro;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("grade")
public class gradeController {
@Autowired
    private gradeservice gradeservice;
    @GetMapping("/listAll")
    public List<gradebro> listAll() {
        return gradeservice.listAll();
    }

    @GetMapping("/getByCourseId/{courseId}")
    public List<gradebro> getByCourseId(@PathVariable int courseId) {
        return gradeservice.getByCourseId(courseId);
    }

    @PostMapping("/update")
    public String update(@RequestBody grade grade) {
        gradeservice.updateGrade(grade);
        return "数据更新成功了喵(=^・ω・^=)ノ☆";
    }

    @GetMapping("/getByRange/{minScore}/{maxScore}")
    public List<gradebro> getByRange(@PathVariable double minScore, @PathVariable double maxScore) {
        return gradeservice.getByRange(minScore, maxScore);
    }
}
